#ifndef ASSIGNMENT3_QUEUE_H
#define ASSIGNMENT3_QUEUE_H

#include "QueueADT.h"

class Customer;

#define MAX_SIZE 100

template <class T> class Node {
public:
  T data;
  Node<T> *next;
};

template <class T> class Queue : public QueueADT<T> {
private:
  Node<T> *front;
  Node<T> *back;
  int count;
  int maxQueueSize;

public:
  Queue(int queueSize) {
    front = nullptr;
    back = nullptr;
    count = 0;
    maxQueueSize = queueSize;
  }

  ~Queue() {
    Node<T> *temp;
    while (front != nullptr) {
      temp = front;
      front = front->next;
      delete temp;
    }
    back = nullptr;
    count = 0;
  }

  void enqueue(const T &newItem) {
    Node<T> *newNode = new Node<T>;
    newNode->data = newItem;
    newNode->next = nullptr;
    if (front == nullptr) {
      front = newNode;
      back = newNode;
    } else {
      back->next = newNode;
      back = newNode;
    }
    count++;
  }

  T &dequeue() {
    Node<T> *temp = front;
    front = front->next;
    count--;
    return temp->data;
  }

  T &peek() { return front->data; }

  void print() {
    Node<T> *temp = front;
    while (temp != nullptr) {
      std::cout << temp->data << " ";
      temp = temp->next;
    }
    std::cout << std::endl;
  }

  bool isEmpty() { return count == 0; }

  bool isFull() { return count == maxQueueSize; }
};

Queue<Customer> readCustomers();

#endif // ASSIGNMENT3_QUEUE_H
